package com.yao.sys.entity.dto;

import java.util.Arrays;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yao.common.resp.DTree;
import com.yao.sys.entity.MenuEntity;

import lombok.Data;
import lombok.ToString;

/**
 * 菜单表
 *
 * @author autoCode
 * @version 1.0.0-SNAPSHOT
 * @date 2020-04-09
 */
@Data
@TableName("sys_menu")
@ToString(callSuper = true)
public class MenuDto extends MenuEntity {

    @TableField(exist = false)
    private List<MenuDto> child;


    public static DTree of(MenuDto dto){
        DTree dTree = new DTree();

        BeanUtils.copyProperties(dto, dTree);

        dTree.setTitle(dto.getName());
        dTree.setCheckArr(Arrays.asList(new DTree.CheckArr().setType("0").setChecked("0")));

        return dTree;
    }
}